home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / mlibv22.zip / DEMO2.BAS < prev    next >
BASIC Source File  |  1993-01-27  |  6KB  |  169 lines

  1. DEFINT A-Z
  2. '******************************** DEMO2.BAS *********************************
  3. '*                                                                          *
  4. '*     : Demo on how to use the function; ShowPtrM%.                        *
  5. '*     :                                                                    *
  6. '* NOTE: In order for this demo to run you must start the QB editor         *
  7. '*     : along with the library MLIBN.QLB  (ie., QB/L MLIBN).               *
  8. '*     :                                                                    *
  9. '*     : IF YOU ARE NOT USING QuickBASIC 4.0- 4.5 SEE PAGE 2 OF THE MANUAL  *
  10. '*     : BEFORE TRYING TO RUN THIS DEMO!                                    *
  11. '*     :                                                                    *
  12. '*                                                                          *
  13. '****************************************************************************
  14. '                                                '
  15. '$INCLUDE: 'mlib.inc'                            '
  16.                                                  '
  17. DECLARE SUB GetInput (NumCalls%)                 '
  18. DECLARE SUB KP ()                                '
  19. DECLARE SUB M1 ()                                '
  20. DECLARE SUB M2 (X%)                              '
  21. DECLARE SUB MP ()                                '
  22.                                                  '
  23. SCREEN 0: CLS                                    '
  24.                                                  '
  25. CALL InitPointer(X%)                             'Must initialize the mouse.
  26.                                                  '
  27. M1                                               'Message 1.
  28.                                                  '
  29. CALL ShowPointer                                 '
  30.                                                  '
  31. GetInput NumCalls%                               '
  32.                                                  '
  33. FOR z = 1 TO NumCalls%                           'Hide X number of times.
  34.    CALL HidePointer                              '
  35. NEXT                                             '
  36.                                                  '
  37. M2 (NumCalls%)                                   'Message 2.
  38. MP                                               'Check mem.
  39.                                                  '
  40. BSize% = GetSizeM%                               'Get mouse state size, in
  41.                                                  'bytes.
  42. Buffer$ = SPACE$(BSize% * 2)                     'Build buffer for asm proc.
  43.                                                  '
  44. ErrNm% = ShowPtrM%(Buffer$)                      'Do it.
  45.                                                  '
  46. MP                                               'Print mem used.
  47.                                                  '
  48. Buffer$ = ""                                     'Release mem.
  49.                                                  '
  50. IF ErrNm% THEN                                   'Unable to complete task.
  51.                                                  '
  52.    PRINT "ERROR! Unable to complete task..."     'Insufficient buffer size.
  53.    BEEP                                          '
  54.                                                  '
  55. ELSE                                             'Job done.
  56.                                                  '
  57.    PRINT "Pointer is now visible again..."       '
  58.                                                  '
  59. END IF                                           '
  60.                                                  '
  61. KP                                               'Pause for a key press.
  62. CALL HidePointer: CLS : END                      'We are done.
  63.  
  64. DEFSNG A-Z
  65. '
  66. '*******************************
  67. '
  68. 'Number of calls to HidePointer.
  69. '
  70. '*******************************
  71. '
  72. SUB GetInput (NumCalls%)
  73.  
  74. IP:
  75.  
  76. INPUT "Hide the pointer how many times [1 to 100]"; NumCalls%: CLS
  77. IF NumCalls% < 1 OR NumCalls% > 100 THEN PRINT "Redo..": GOTO IP
  78.  
  79. END SUB
  80.  
  81. SUB KP
  82.  
  83. VIEW PRINT
  84.  
  85. LOCATE 24
  86.  
  87. HidePointer
  88. PRINT "Press a key to continue..."
  89. ShowPointer
  90.  
  91. Hld$ = INPUT$(1)
  92.  
  93. CLS
  94.  
  95. END SUB
  96.  
  97. SUB M1
  98.  
  99. PRINT "                Demo on how to use the function ShowPtrM%."
  100. PRINT "                =================================================="
  101. PRINT
  102. PRINT "                First we must initialize the mouse and show the"
  103. PRINT "                mouse pointer. Then we will call HidePointer a"
  104. PRINT "                few times (pretending our program lost track of"
  105. PRINT "                how many times we hid the pointer)."
  106. PRINT
  107. PRINT "                Next we will call ShowPtrM%, this will restore"
  108. PRINT "                the mouse pointer on the screen."
  109. PRINT
  110. PRINT "                --------------------------------------------------"
  111. PRINT
  112. PRINT "                DECLARE FUNCTION ShowPtrM%(Buffer$)"
  113. PRINT "                Syntax: ErrNum% = ShowPtrM%(Buffer$)"
  114. PRINT
  115. PRINT "                ErrNum% returns a -1, if unsuccessful."
  116. PRINT "                See the manual for more information."
  117. PRINT
  118. PRINT "                --------------------------------------------------"
  119. PRINT "                                               Assembler function."
  120.  
  121. KP
  122.  
  123. PRINT
  124.  
  125. END SUB
  126.  
  127. SUB M2 (X%)
  128.  
  129. PRINT
  130. PRINT "       ------------------------------------------------------------"
  131. PRINT
  132. PRINT "       Mouse Driver keeps count by:"
  133. PRINT
  134. PRINT "        - Each call to HidePointer, will increment count by one"
  135. PRINT
  136. PRINT "        - Each call to ShowPointer, will decrement count by one."
  137. PRINT
  138. PRINT "        - Pointer is visible only when the count equals zero."
  139. PRINT
  140. PRINT "       What ShowPtrM% does:"
  141. PRINT
  142. PRINT "        - Check count value and reset it to zero."
  143. PRINT
  144. PRINT "       ------------------------------------------------------------"
  145. PRINT
  146. PRINT "       Now that we have called HidePointer "; X%; " times, the next job"
  147. PRINT "       is tell ShowPtrM% to restore the pointer on the screen."
  148.  
  149.  
  150. KP
  151.  
  152. END SUB
  153.  
  154. DEFINT A-Z
  155. SUB MP STATIC
  156.  
  157. IF NOT X THEN
  158.    MEM1& = FRE(-1)
  159.    X = -1
  160. ELSE
  161.    MEM2& = FRE(-1)
  162.    MEM3& = MEM1& - MEM2&
  163.    PRINT "Amount of memory used: "; MEM3&; " bytes."
  164.    X = 0
  165. END IF
  166.  
  167. END SUB
  168.  
  169.